/*   Copyright 2012 Fernando Moreno Ruiz All Rights Reserved.
 *
 * 	 This file is part of pyPhotosMixer.
 *
 *   pyPhotosMixer is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   pyPhotosMixer is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with pyPhotosMixer.  If not, see <http://www.gnu.org/licenses/>.
 * */
import QtQuick 1.1

Rectangle {
    width: parent.width
    height: parent.height
    color:"grey"
    property int _spacing: 10
    property bool camera1Loaded:  browserCamera1.opacity == 0
    property bool camera2Loaded:  browserCamera2.opacity == 0
    function loadDatePhotos(){
//        entra(models.maxDateTotal)
//        entra(models.minDateTotal)
//        entra(models.folderCamera1)
//        entra(models.folderCamera2)
        entra("LOAD")
    }
    ListPhotos{
        id:lvPhotosCamera1
        delegate: DelegateVisualizer{listPhotos: lvPhotosCamera1}
        model: models.modelExifCamera1
        width: parent.width
        spacing: _spacing
        height: parent.height*(6/16)
        anchors.top: parent.top
        anchors.topMargin: parent.height/16
        orientation: ListView.Horizontal
        //        cacheBuffer: 1000
    }
    Rectangle{
        width: parent.width - 4
        height: 70
        anchors.centerIn: parent
        color:"transparent"
        DatePhotos{
            id:datePhotos1
            ferFormat:true
            anchors.verticalCenter: parent.verticalCenter
            anchors.verticalCenterOffset: displayed?-parent.height : -parent.height/4
        }
        Connections{
            target:models
            onAllModelsLoaded: {
                console.log("JAAAAAAAAAAAAA--------------------------")
                console.log("models.maxDateTotal:"+models.maxDateTotal)
                datePhotos1.ferFormat = models.camera1FerFormatAvailable
                datePhotos1.maxDate = models.maxDateTotal
                console.log("models.minDateTotal:"+models.minDateTotal)
                datePhotos1.minDate = models.minDateTotal
                datePhotos1.folderDir = models.folderCamera1
                datePhotos1.listView = lvPhotosCamera1
                console.log("models.modelExifCamera1:"+models.modelExifCamera1.count)
                datePhotos1.model=models.modelExifCamera1

                datePhotos2.ferFormat = models.camera2FerFormatAvailable
                datePhotos2.maxDate = models.maxDateTotal
                datePhotos2.minDate = models.minDateTotal
                datePhotos2.folderDir = models.folderCamera2
                datePhotos2.listView = lvPhotosCamera2
                console.log("models.modelExifCamera2:"+models.modelExifCamera2.count)
                datePhotos2.model=models.modelExifCamera2
            }
//            onModelCamera1Loaded:{
//                console.log("Max Date Total1:" +models.maxDateTotal)
//                datePhotos1.maxDate = models.maxDateTotal
//                console.log("Min Date Total1:" +models.minDateTotal)
//                datePhotos1.minDate = models.minDateTotal
//                datePhotos1.folderDir = models.folderCamera1
//                datePhotos1.listView = lvPhotosCamera1
//                datePhotos1.model=models.modelExifCamera1
//            }
//            onModelCamera2Loaded:{
//                datePhotos2.maxDate = models.maxDateTotal
//                datePhotos2.minDate = models.minDateTotal
//                datePhotos2.folderDir = models.folderCamera2
//                datePhotos2.listView = lvPhotosCamera2
//                datePhotos2.model=models.modelExifCamera2
//            }
        }
        DatePhotos{
            id:datePhotos2
//            model:models.modelExifCamera2
//            maxDate: models.maxDateTotal
//            minDate: models.minDateTotal
//            folderDir: models.folderCamera2
//            listView: lvPhotosCamera2
            ferFormat:true
            anchors.verticalCenter: parent.verticalCenter
            anchors.verticalCenterOffset: displayed? parent.height : parent.height/4
            //            anchors.bottom: parent.bottom
            down:true
        }
        z:200
    }
    ListPhotos{
        id:lvPhotosCamera2
        delegate: DelegateVisualizer{listPhotos: lvPhotosCamera2}
        spacing: _spacing
        model:models.modelExifCamera2
        anchors.topMargin: parent.height/8
        anchors.top: lvPhotosCamera1.bottom
        width: parent.width
        anchors.bottom: parent.bottom
        anchors.bottomMargin: parent.height/16
        orientation: ListView.Horizontal
        //        cacheBuffer:1000
    }
    Behavior on opacity{
        NumberAnimation{duration:700}
    }
}
